package com.ruoyi.huanjing.entity.dto;

import com.ruoyi.huanjing.entity.TimeDopplerSpectrum;

/**
 * 时变多普勒谱DTO
 */
public class TimeDopplerDTO {
    private double[] dopplerFrequencies; // 多普勒频率（X轴）
    private double[] times;              // 时间点（Y轴）
    private double[][] spectrumDensity;  // 谱密度（数据值）

    // 从实体类构建DTO
    public static TimeDopplerDTO fromEntity(TimeDopplerSpectrum entity) {
        TimeDopplerDTO dto = new TimeDopplerDTO();
        if (entity == null) {
            dto.setDopplerFrequencies(new double[0]);
            dto.setTimes(new double[0]);
            dto.setSpectrumDensity(new double[0][0]);
            return dto;
        }

        dto.setDopplerFrequencies(entity.getDopplerFrequencies() != null ? entity.getDopplerFrequencies() : new double[0]);
        dto.setTimes(entity.getTimes() != null ? entity.getTimes() : new double[0]);
        dto.setSpectrumDensity(entity.getSpectrumDensity() != null ? entity.getSpectrumDensity() : new double[0][0]);
        return dto;
    }

    // Getter & Setter
    public double[] getDopplerFrequencies() {
        return dopplerFrequencies;
    }

    public void setDopplerFrequencies(double[] dopplerFrequencies) {
        this.dopplerFrequencies = dopplerFrequencies;
    }

    public double[] getTimes() {
        return times;
    }

    public void setTimes(double[] times) {
        this.times = times;
    }

    public double[][] getSpectrumDensity() {
        return spectrumDensity;
    }

    public void setSpectrumDensity(double[][] spectrumDensity) {
        this.spectrumDensity = spectrumDensity;
    }
}